<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.biz.utils.ConfigUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html class="no-js">
<head>
  <meta charset="UTF-8">
  <title>商品详情</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="format-detection" content="telephone=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <jsp:include page="/jsp/inc.jsp"></jsp:include>
    <style>
        .gdsinfodescription p img{
            max-width: 100%;
        }
        .orderworked{
            padding-left: .9rem;
            background-image: url(<%=basePath%>resources/image/icon-ok.png);
            background-position: .3rem center;
            background-size: .48rem .48rem;
            background-repeat: no-repeat;
            background-color: #00a0e9;
            color: #fff;
            font-size: 0.32rem;
            height: 1.0rem;
            line-height: 1.0rem;
        }
        .backhome{
            background: #fff;
            color:#ff6666;
            border-top: 1px solid #e3e3e3;
        }

    </style>

</head>
<body style="padding-bottom: 1.1rem;">
<c:if test="${pageChargeType == 'alreadyCharge' }">
    <div class="orderworked">兑换成功</div>
</c:if>
<div class="gdsinfotop">
    <!-- 轮播图 -->
    <div class="m-slider" data-ydui-slider>
        <div class="slider-wrapper">
            <c:choose>
                <c:when test="${not empty list}">
                    <c:forEach items="${list}"  var="obj" varStatus="vs">
                        <div class="slider-item">
                            <a href="javascript:;">
                                <img src="<%=ConfigUtil.get("OSSURL")%>${obj.path}" data-url="">
                            </a>
                        </div>
                    </c:forEach>
                </c:when>
            </c:choose>
        </div>
        <div class="slider-pagination"></div>
    </div>
    <!-- 轮播图结束 -->
    <div class="gdsinfotitle">${pWxGoods.name}</div>
    <div class="gdinfocodesale">
        <div class="fl-l">${pWxGoods.price}积分</div>
        <div class="fl-r">已售  ${pWxGoods.sales}</div>
        <br class="clear"/>
    </div>
</div>
<div class="gdsinfodescription">
    ${pWxGoods.info}
</div>
<c:if test="${pageChargeType == 'newCharge' }">
    <div class="fixedbtmbtn">
        <button type="button" onclick="doCharge();" class="btmbtn-blue toduihuan">立即兑换</button>
    </div>
</c:if>
<c:if test="${pageChargeType == 'doCharge' }">
    <div class="fixedbtmbtn">
        <button type="button" onclick="aftercancel('${code}')" class="btmbtn-blue">兑换二维码</button>
    </div>
</c:if>
<c:if test="${pageChargeType == 'alreadyCharge' }">
    <div class="fixedbtmbtn">
        <button type="button" onclick="toGoodsList();" class="btmbtn-blue backhome">返回商城</button>
    </div>
</c:if>


<script src="<%=basePath%>resources/js/ydui.js"></script>
<script type="text/javascript">

    function aftercancel(code){
        window.location.href='${pageContext.request.contextPath}/goods/toOrderQrcode.ac?code='+code;
    };

    function doCharge()
    {
        if(parseFloat('${pWxGoods.price}') > parseFloat('${pbaseUser.integralNow}'))
        {
            window.YDUI.dialog.alert("当前可兑换积分不足，无法兑换！");
            return false;
        }
        window.YDUI.dialog.confirm('是否兑换此商品', '兑换后将不可取消兑换', function () {
            var goodsId = '${goodsId}';
            $.ajax({
                url:'${pageContext.request.contextPath}/goods/doCharge.ac',
                type:'post',
                data:{goodsId:goodsId},
                dataType:'json',
                success:function(data){
                    if(data.success)
                    {
                        aftercancel(data.code);
                    }else{
                        window.YDUI.dialog.alert(data.msg);
                    }
                }
            });
        });
    }

    function toGoodsList(){

        window.location.href='${pageContext.request.contextPath}/goods/toGoodsList.ac';
    }
</script>
</body>
</html>

